extends CardState

const MOUSE_Y:=138

func enter()->void:
	var offset:=Vector2(card.parent.size.x/2,-card.size.y/2)
	offset.x-=card.size.x/2
	# 缓动动画
	card.tweenToPos(card.parent.global_position+offset,0.2)
	card.dropArea.monitoring=false

	Events.cardAimStarted.emit(card)

func exit()->void:
	Events.cardAimEnded.emit(card)

func onInput(event:InputEvent)->void:
	var mouseMotion:=event is InputEventMouseMotion
	var mouseBottom:=card.get_global_mouse_position().y>MOUSE_Y

	# 取消瞄准
	if (mouseMotion and mouseBottom) or event.is_action_pressed("right_mouse"):
		transition.emit(self,State.BASE)
	# 卡牌释放
	elif event.is_action_released("left_mouse") or event.is_action_pressed("right_mouse"):
		get_viewport().set_input_as_handled()
		transition.emit(self,State.RELEASED)